<%@ page language="java" import="java.util.*,com.hs.auth.model.*,com.hs.core.utils.*" pageEncoding="utf-8"%>
<%
HsOrg accObj = (HsOrg)request.getAttribute("obj");


String flag = (String)request.getAttribute("flag");

List orgList = (List)request.getAttribute("orgList");
List roleList = (List)request.getAttribute("roleList");
String userrole = (String)request.getAttribute("userrole");
if(null == userrole){
	userrole="";
}
String status = "";
if(null != accObj){
	status = String.valueOf(accObj.getIsuse());
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<title></title>
<%@ include file="../include.jsp"%>   
<script language="javascript" type="text/javascript" src="<%=path %>/thirtpart/My97DatePicker/WdatePicker.js"></script>

<style>.tac{text-align:center}</style>
 <script language="javascript" type="text/javascript">
 
 var flag = true;
 function callBackForCheckId(message){
 	  
 	    if("0" == message)
 	       alert("此单位名可以录入");
 	    else{
 	       alert("此单位名已存在，不可录入");  
 	    } 
 }
  function callBackForCheckId1(message){
 	  
 	    if("0" != message) {
 	       alert("此单位名已存在，不可录入"); 
 	       flag =false;
 	    } 
 }
 
 function checkOrgName(){
 	 var orgname = orgform.orgname.value;
     if(isNull(orgname)){
		        	alert("单位名不能为空!");
		            orgform.orgname.focus();
		            return;
     }
     authdwr.isOrgDouble(orgname,callBackForCheckId);  
 
 }
 
 function saveData(){
           var orgname = orgform.orgname.value;
            var id = orgform.id.value; 
             if(isNull(id)){
             	 if(isNull(orgname)){
		        	alert("单位名不能为空!");
		            orgform.orgname.focus();
		            return;
             	 }
              	 authdwr.isOrgDouble(orgname,callBackForCheckId1);   
             }
              setTimeout("checkform();",1000)
 	     
 
 }
 function checkform(){ 
    var id = orgform.id.value;
    var orgname = orgform.orgname.value; 
    
     var orgtype = orgform.orgtype.value; 
     var orgcode = orgform.orgcode.value; 
     var parentunit = orgform.parentunit.value; 
     var province = orgform.province.value; 
     var orgarea = orgform.orgarea.value; 
     var postaddress = orgform.postaddress.value; 
     
    if(isNull(id)){
    	//新注册单位
        if(isNull(orgname)){
        	alert("单位名称不能为空！");
            orgform.orgname.focus();
            return;
        }
        
        if(isNull(orgtype)){
        	alert("请选择单位性质！");
            orgform.orgtype.focus();
            return;
        }
         if(isNull(parentunit)){
        	alert("请选择主管部门！");
            orgform.parentunit.focus();
            return;
        }
        
        if(isNull(orgcode)){
        	alert("组织代码不能为空！");
            orgform.orgcode.focus();
            return;
        }
        
        if(isNull(province)){
        	alert("请选择省份！");
            orgform.province.focus();
            return;
        }
        
        if(isNull(orgarea)){
        	alert("请选择地域！");
            orgform.orgarea.focus();
            return;
        }
        
    
    }else{
       if(isNull(orgname)){
        	alert("单位名称不能为空！");
            orgform.orgname.focus();
            return;
        } 
    }
    if(flag)
 	  orgform.submit(); 
 } 
 
 
 function addIS(){
    jQuery("parentunit").AddIncSearch({
        maxListSize   : 20,
        maxMultiMatch : 50
    });
}
function removeIS(){
    jQuery("parentunit").RemoveIncSearch();
}
jQuery(document).ready(addIS); 
 </script>
 
</head>

<body class="cont_body" onload="defV('<%=accObj == null?"null":StringUtilTool.NULL2Blank(accObj.getProvince()) %>','<%=accObj == null?"null":StringUtilTool.NULL2Blank(accObj.getOrgarea()) %>');">
<form name="orgform" action="<%=basePath %>/auth/saveOrg.do" method="post">
    <table border="0" cellspacing="0" cellpadding="0" class="new"> 
      
      <caption>单位信息(红色<font color=red>*</font>为必填项)</caption> 
      <tr>
        <td style="width:15%">单位名称</td>
        <td  colspan=3 nowrap><input type="text" name="orgname" value="<%=accObj==null?"":accObj.getOrgname() %>" style="width:65%" <%if(null != accObj){out.print(" disabled");} %>/><font color=red><strong>*</strong></font>
        <input type="hidden" name="id" value="<%=accObj==null?"":accObj.getId() %>"  />
        <input type="button" value="单位名称检测" onclick="checkOrgName();"/>
        </td> 
      </tr>
       <tr>
        <td width="15%">单位别名</td>
        <td width="85%" colspan=3><input type="text" name="othername" value="<%=accObj == null?"":StringUtilTool.NULL2Blank(accObj.getOthername()) %>" style="width:95%"></td>
         
      </tr>
      <tr>
        
        <td width="15%">单位性质</td>
        <td width="85%" colspan=3>
             <%=DictCacheUtil.getInst().selectStrWithDefault("orgtype","width:95%",accObj==null?null:(accObj.getOrgtype())+"","4") %>
           <font color=red><strong>*</strong>
        </td>
      </tr>
      <tr>
        <td width="15%">主管部门 </td>
        <td width="85%" colspan=3>
            <%=DictCacheUtil.getInst().selectStrWithDefault("parentunit","width:95%",accObj==null?null:(accObj.getParentunit())+"","10") %><font color=red><strong>*</strong>
        </td>
        
      </tr>
      <tr>
         
        <td width="15%">组织代码</td>
        <td width="85%" colspan=3><input type="text" name="orgcode" value="<%=accObj == null?"":StringUtilTool.NULL2Blank(accObj.getOrgcode()) %>" style="width:90%"><font color=red><strong>*</strong></td>
      </tr>
      <tr>
        <td width="15%">所在省份</td>
        <td width="85%" colspan=3>
        <select name="province" id="select"  onchange="toSubSelect(this.value)" style="width:95%">
        </select>
        <font color=red><strong>*</strong></font>
       </td>   
      </tr>
      <tr> 
        <td width="15%">所在区域</td>
        <td width="85%" colspan=3>
         <select name="orgarea" id="subSelect" style="width:95%">
        </select>
        <font color=red><strong>*</strong></font>
        </td>
      </tr>
      <tr>
        <td width="15%">国资企业</td>
        <td width="35%">
        <input type="radio" value='1' name="iscontry" <%if("1".equals(accObj == null?"":(accObj.getIscontry()+""))){ out.print(" checked");} %>/>是
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value='0' name="sex" <%if("0".equals(accObj == null?"":(accObj.getIscontry()+""))){ out.print(" checked");} %>/>否</td></td>
        <td width="15%">重点大学</td>
        <td width="35%"><input type="radio" value='1' name="iszhongdian" <%if("1".equals(accObj == null?"":(accObj.getIszhongdian()+""))){ out.print(" checked");} %>/>是
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" value='0' name="sex" <%if("0".equals(accObj == null?"":(accObj.getIszhongdian()+""))){ out.print(" checked");} %>/>否</td>
      </tr>
       
       <tr>
        <td>单位地址</td>
        <td colspan=3><input type="text" name="postaddress" style="width:96%" value="<%=accObj == null?"":StringUtilTool.NULL2Blank(accObj.getPostaddress()) %>" style="width:96%"></td> 
      </tr>
      <tr>
        <td width="15%">单位邮编</td>
        <td width="35%"><input type="text" name="postnum" value="<%=accObj == null?"":StringUtilTool.NULL2Blank(accObj.getPostnum()) %>" style="width:90%"></td> 
        <td width="15%">备注</td>
        <td colspan=3>
        <input type="text" name="memo" value="<%=accObj == null?"":StringUtilTool.NULL2Blank(accObj.getMemo()) %>" style="width:96%" />
        </td>
      </tr>
      <tr>
        <td width="15%">开户银行</td>
        <td colspan=3><input type="text" name="bankname" value="<%=accObj == null?"":StringUtilTool.NULL2Blank(accObj.getBankname()) %>" style="width:96%"></td> 
      </tr>
       <tr>
        <td width="15%">银行账户</td>
        <td colspan=3><input type="text" name="banknum" value="<%=accObj == null?"":StringUtilTool.NULL2Blank(accObj.getBanknum()) %>" style="width:96%"></td> 
      </tr>
       <tr style="display:none">
	        <td width="15%">单位状态</td>
	        <td colspan=3>
	        <select name="isuse" style="width:96%">
	          <option value="1" <%if("1".equals(status)){ out.print(" selected");} %>>有效</option>
              <option value="0" <%if("0".equals(status)){ out.print(" selected");} %>>无效</option>
            </select><font color=red><strong>*</strong></font>
	      	</td>
      	</tr>
        <td colspan=4 align="center"> 
        	<input name="" type="button" value="保存" onclick="saveData();" class="butt2" />
        </td> 
      </tr> 
    </table>  
</form>
</body>
</html>
<script>
<%if(null!= flag){ %> 
    alert("保存成功！");
    window.parent.list.frameElement.src = window.parent.list.frameElement.src; 
<%}%>
</script>
